package com.enjoyor.soa.traffic.rest.tsms.dubbo.impl;

import org.springframework.stereotype.Component;


import com.alibaba.dubbo.config.annotation.Reference;
import com.enjoyor.soa.traffic.api.dto.tsms.RouteInfoDto;
import com.enjoyor.soa.traffic.api.service.dubbo.tsms.IDubboRouteInfoService;
import com.enjoyor.soa.traffic.rest.tsms.dubbo.IRouteInfoConsumeService;
import com.enjoyor.soa.traffic.util.helper.GeomtryHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;
import com.enjoyor.soa.traffic.util.pojo.ResultPojo;
import oracle.spatial.geometry.JGeometry;

@Component
public class RouteInfoConsumeService implements IRouteInfoConsumeService{

	@Reference(version = "1.0.0", timeout = 10000)
    //@Reference(version = "1.0.0", timeout = 10000, url="dubbo://192.168.56.8:21241")
	private IDubboRouteInfoService iDubboRouteInfoService;
	
	@Override
	public ResultPojo getRouteInfoPage(Page page, String routeId, String routeName, String taskId,
			String routeStartPlace, String routeTargetPlace, String routeTypeId) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		resultPojo = iDubboRouteInfoService.getRouteInfoPage(page, routeId, routeName, taskId, routeStartPlace,
				routeTargetPlace, routeTypeId);
		return resultPojo;
	}

	@Override
	public ResultPojo getRouteInfoList(String routeId, String routeName, String taskId, String routeStartPlace,
			String routeTargetPlace, String routeTypeId) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		resultPojo = iDubboRouteInfoService.getRouteInfoList(routeId, routeName, taskId, routeStartPlace,
				routeTargetPlace, routeTypeId);
		return resultPojo;
	}

	@Override
	public ResultPojo insertRouteInfo(RouteInfoDto routeInfoDto, String personName) {
		// TODO Auto-generated method stub
		String strArea = routeInfoDto.getStrArea();
		JGeometry jGeometry = GeomtryHelper.getGeomWithGson(strArea);
		routeInfoDto.setRouteGeo(jGeometry);
		ResultPojo resultPojo = iDubboRouteInfoService.insertRouteInfo(routeInfoDto, personName);
		return resultPojo;
	}

	@Override
	public ResultPojo editRouteInfo(RouteInfoDto routeInfoDto, String personName) {
		// TODO Auto-generated method stub
		String strArea = routeInfoDto.getStrArea();
		JGeometry jGeometry = GeomtryHelper.getGeomWithGson(strArea);
		routeInfoDto.setRouteGeo(jGeometry);
		ResultPojo resultPojo = iDubboRouteInfoService.editRouteInfo(routeInfoDto, personName);
		return resultPojo;
	}

	@Override
	public ResultPojo deleteRouteInfo(String routeId, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = iDubboRouteInfoService.deleteRouteInfo(routeId, personName);
		return resultPojo;
	}

	@Override
	public ResultPojo changeRouteType(String taskId, String routeId, String personName) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = iDubboRouteInfoService.changeRouteType(taskId, routeId, personName);
		return resultPojo;
	}

	@Override
	public ResultPojo getRouteProcress(String executeDate, String taskName, String beforeLicensePlate, String schemeId) {
		// TODO Auto-generated method stub
		ResultPojo resultPojo = new ResultPojo();
		resultPojo = iDubboRouteInfoService.getRouteProcress(executeDate, taskName, beforeLicensePlate, schemeId);
		return resultPojo;
	}

}
